#ifndef _BL_CONFIG_H_
#define _BL_CONFIG_H_

#define VERSION "v1.0usb"
#define COMPILE_TIME_STAMP __DATE__" "__TIME__
#define T8_BOOTLOADVERSION "3.5.f"
#define ELDR_MAGIC 0xadeafbee

/* default kernel boot argument */
#define BOOT_ARG0 0
#define BOOT_ARG1 0

// Clock settings
#define FCLK 400000000
//#define FCLK 296352000
//#define FCLK 203000000
//#define FCLK 192000000
#define HCLK (FCLK/3)
#define PCLK (HCLK/2)
//#define PCLK (HCLK)
#define UCLK 48000000

// Fin=16.9344MHz
#define M_MDIV            63
#define M_PDIV            4
#define M_SDIV            0
// Fin=16.9344MHz Fout=48MHz
#define U_MDIV            60
#define U_PDIV            4
#define U_SDIV            2

// for uart Baud rate.
//rUBRDIV0=( (int)(pclk/16./baud+0.5) -1 )
#define UBRDIV0_VAL    ((int)(PCLK/16./115200+0.5)-1)

// BUSWIDTH : 16,32
#define BUSWIDTH    (32)

/****************************************************************
 *
 *         Flash Memory Map
 *
 ****************************************************************/
#define BL_FLASH_START            0x00000000
#define BL_FLASH_LENGTH            0x00020000

#define TAT_FLASH_START            0x00020000
#define TAT_FLASH_LENGTH        0x00020000

#define KERNEL_FLASH_START        0x00040000
#define KERNEL_FLASH_LENGTH        0x00100000

#define ROOT_FLASH_START        0x00140000
#define ROOT_FLASH_LENGTH        0x00380000

#define USER_FLASH_START        0x004C0000
#define USER_FLASH_LENGTH        0x01800000

#define USERDATA_FLASH_START    0x01CC0000
#define USERDATA_FLASH_LENGTH    0x00220000

#define PTABLE_FLASH_START        0x01EE0000
#define PTABLE_FLASH_LENGTH        0x00020000

#define INITIMAGE_FLASH_START    0x01F00000
#define INITIMAGE_FLASH_LENGTH    0x00100000

/* Loader */
#define SPL_RAM_ADDRESS         0x33c00000
#define SPL_SIZE                0x100

#define DOC_PAGES_IN_BLOCK     (128)
#define DOC_PAGE_SIZE          (512)
#define DOC_BLOCK_SIZE         (DOC_PAGE_SIZE*DOC_PAGES_IN_BLOCK)

/* Size of FLASH storage */
#define SIZE_128M                0x08000000L             /*128M*/
#define PART0_LENGTH            (1024 * 256)      /* ELDR */
#define PART1_LENGTH            (1024 * 256)      /* TATT */
#define PART2_LENGTH            (1024 * 512)      /* LOGO*/
#define TATT_LENGTH             PART1_LENGTH
#define LOGO_LENGTH             PART2_LENGTH
#define PART3_LENGTH            (1024 * 5 * 1024L)      /* Elastos*/
#define KERNEL_LENGTH           PART3_LENGTH
#define PART4_LENGTH            (1024 * 20 * 1024L)      /* User Storate 0 */
#define PART5_LENGTH            (1024 * 40 * 1024L)      /* User Storate 1*/
#define PART6_LENGTH            (1024 * 40 * 1024L)      /* User Storate 2*/
#define PART7_LENGTH            (1024 * 10 * 1024L)      /* User Storate 3*/

#define PART0_OFFSET            0
#define PART1_OFFSET            (PART0_OFFSET + PART0_LENGTH)
#define PART2_OFFSET            (PART1_OFFSET + PART1_LENGTH)
#define PART3_OFFSET            (PART2_OFFSET + PART2_LENGTH)
#define PART4_OFFSET            (PART3_OFFSET + PART3_LENGTH)
#define PART5_OFFSET            (PART4_OFFSET + PART4_LENGTH)
#define PART6_OFFSET            (PART5_OFFSET + PART5_LENGTH)
#define PART7_OFFSET            (PART6_OFFSET + PART6_LENGTH)
#define LOADER_OFFSET           PART0_OFFSET
#define LOGO_OFFSET             PART2_OFFSET
#define KERNEL_OFFSET           PART3_OFFSET

/* memory address */
#define RAM_START                0x30000000
#define RAM_STACK_END_OFFSET_FROM_RAM_START 0x03DFFFFC
#define LOADER_RAM_START          0x33c00000
#define KERNEL_RAM_START        0x30020000
#define UDL_RAM_OFFSET          (32*1024*1024) // 32M

/* internal timer resolution */
#define TIMER_TICK_PER_SEC 100 /* timer interrupt per sec. */

/* LCD */
#define LCD_BPP_DIS     16  // bit per pixel
#define LCD_WIDTH  240
#define LCD_HEIGHT 320
#define LCD_FRAMEBUFFER  0x33fba000
#define LCD_FRAMEBUFSIZE (LCD_WIDTH * LCD_HEIGHT * 2)

/* Audio */
#define AUDIO_DMABUFFER 0x33e80000

/* Temp Buffers */
#define TEMP_BUFFER 0x32800000

#endif // _BL_CONFIG_H_
